home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Devices / CD-ROM / How to Detect a CD / Not used in this example / Determine Devices using SCSI / main.cp < prev   
Encoding:
Text File  |  1995-10-18  |  2.2 KB  |  93 lines  |  [TEXT/MPS ]

  1. #include <iostream.h>
  2. #include "cscsi.h"
  3.  
  4. /*
  5. //          0          Direct-access device (disk)
  6. //          1          Sequential-access device (tape)
  7. //          2          Printer
  8. //          3          Processor
  9. //          4          Write-once device (some optical disks)
  10. //          5          CD-ROM
  11. //          6          Scanner
  12. //          7          Optical memory (some optical disks)
  13. //          8          Medium changer
  14. //          9          Communications
  15. //          10-11      Graphic Arts Pre-Press devices
  16. */
  17.  
  18. Byte    buf[256];
  19.  
  20. void    main( void )
  21. {
  22.     long    i;
  23.     short    id;
  24.     CSCSIOp * inq = new CSCSIOp;
  25.     CSCSIOp * cmd = new CSCSIOp;
  26.     CSCSIOp * rew = new CSCSIOp;
  27.     CSCSIOp * load = new CSCSIOp;
  28.     CSCSIOp * sense = new CSCSIOp;
  29.     
  30.     cout << "Test of identifying SCSI Devices" << endl;
  31.     
  32.     inq->set6( 18, 0, 0, 0, 255, 0 );
  33.     inq->setBuf( buf );
  34.     inq->setLen( 255 );
  35.     inq->setDir( dataIn );
  36.     
  37.     //
  38.     // Find the tape drive
  39.     //
  40.     for ( id = 0; id < 7; id++ )
  41.     {
  42.         //
  43.         //First, we issue an INQUIRY to see what kind of device it is.
  44.         //
  45.         inq->keep( USE_CDB | USE_DIR | USE_BUF | USE_LEN );
  46.         inq->setID( id );
  47.         inq->execute();
  48.         if ( inq->getErr() )
  49.                 continue;
  50.         //
  51.         // Byte 0 of INQUIRY data contains the device type.
  52.         //
  53.         switch ( (buf[0] & 0x1f) ) 
  54.         {
  55.             case 0:
  56.                 cout << "Device at SCSI ID " << id << " is a Direct-access device (disk) " << endl;
  57.                 break;
  58.             case 1:
  59.                 cout << "Device at SCSI ID " << id << " is a Sequential-access device (tape) " << endl;
  60.                 break;
  61.             case 2:
  62.                 cout << "Device at SCSI ID " << id << " is a Printer " << endl;
  63.                 break;
  64.             case 3:
  65.                 cout << "Device at SCSI ID " << id << " is a Processor " << endl;
  66.                 break;
  67.             case 4:
  68.                 cout << "Device at SCSI ID " << id << " is a Write-once device (some optical disks) " << endl;
  69.                 break;
  70.             case 5:
  71.                 cout << "Device at SCSI ID " << id << " is a CD-ROM " << endl;
  72.                 break;
  73.             case 6:
  74.                 cout << "Device at SCSI ID " << id << " is a Scanner " << endl;
  75.                 break;
  76.             case 7:
  77.                 cout << "Device at SCSI ID " << id << " is a Optical memory (some optical disks) " << endl;
  78.                 break;
  79.             case 8:
  80.                 cout << "Device at SCSI ID " << id << " is a Medium changer " << endl;
  81.                 break;
  82.             case 9:
  83.                 cout << "Device at SCSI ID " << id << " is a Communications " << endl;
  84.                 break;
  85.             case 10:
  86.             case 11:
  87.                 cout << "Device at SCSI ID " << id << " is a Graphic Arts Pre-Press devices " << endl;
  88.                 break;
  89.             
  90.         }
  91.     }
  92. }
  93.